home *** CD-ROM | disk | FTP | other *** search
/ Master Visual Basic 3 / Master Visual Basic 3 (SAMS Publishing) (1994).ISO / mvprog / original / ch04 / multipad / document.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-06-07  |  2.5 KB  |  83 lines

  1. VERSION 2.00
  2. Begin Form frmDocument 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   7365
  8.    Height          =   4425
  9.    Icon            =   DOCUMENT.FRX:0000
  10.    Left            =   1035
  11.    LinkTopic       =   "Form1"
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4020
  14.    ScaleWidth      =   7365
  15.    Top             =   1140
  16.    Width           =   7485
  17.    Begin CheckBox chkFileHasChanged 
  18.       Caption         =   "File has changed flag"
  19.       Height          =   495
  20.       Left            =   1080
  21.       TabIndex        =   2
  22.       Top             =   2280
  23.       Visible         =   0   'False
  24.       Width           =   2655
  25.    End
  26.    Begin TextBox txtDocument 
  27.       Height          =   495
  28.       Left            =   0
  29.       MultiLine       =   -1  'True
  30.       ScrollBars      =   3  'Both
  31.       TabIndex        =   0
  32.       Top             =   0
  33.       Width           =   1215
  34.    End
  35.    Begin Label lblFilename 
  36.       BorderStyle     =   1  'Fixed Single
  37.       Height          =   495
  38.       Left            =   4440
  39.       TabIndex        =   1
  40.       Top             =   2280
  41.       Visible         =   0   'False
  42.       Width           =   1215
  43.    End
  44. Option Explicit
  45. Sub Form_Load ()
  46.     ggNumChildren = ggNumChildren + 1
  47. End Sub
  48. Sub Form_Resize ()
  49.     Me.txtDocument.Height = Me.ScaleHeight
  50.     Me.txtDocument.Width = Me.ScaleWidth
  51. End Sub
  52. Sub Form_Unload (Cancel As Integer)
  53.     Dim msg, Answer
  54.     ' Before ending the program, check
  55.     ' if the current file has changed, and if
  56.     ' it has, give the user a chance to save it.
  57.     If chkFileHasChanged.Value = 1 Then
  58.        msg = lblFilename.Caption + Chr(13)
  59.        msg = msg + "The file has changed." + Chr(13)
  60.        msg = msg + "Do you want to save current changes?"
  61.        Answer = MsgBox(msg, MB_ICONEXCLAMATION + MB_YESNOCANCEL, "Mulitpad")
  62.        If Answer = IDYES Then
  63.           If UCase(lblFilename.Caption) = UCase("Untitled.txt") Then
  64.              If FileSaveAs() = False Then
  65.                 Cancel = True
  66.              End If
  67.           Else
  68.              SaveFile
  69.           End If
  70.        End If
  71.        If Answer = IDCANCEL Then
  72.           Cancel = True
  73.        End If
  74.     End If
  75.     ' User did not cancel the Close operation
  76.     If Cancel = False Then
  77.        ggNumChildren = ggNumChildren - 1
  78.     End If
  79. End Sub
  80. Sub txtDocument_Change ()
  81.   chkFileHasChanged.Value = 1
  82. End Sub
  83.